<html>
<head><meta charset="utf-8"><title>path trimming problem · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html">path trimming problem</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209283105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209283105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209283105">(Sep 07 2020 at 11:02)</a>:</h4>
<p>Hi,</p>
<p>Our rustc fork made use of <code>tcx.def_path_str</code> in the codegen, which now I believe is disallowed.</p>
<p>What would be the correct way to get the old behaviour in the codegen?</p>
<p>I've tried using <code>tcx.def_path_debug_str</code> and <code>with_no_trimmed_paths</code> to no avail.</p>
<p>Thanks</p>



<a name="209283621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209283621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209283621">(Sep 07 2020 at 11:09)</a>:</h4>
<p>It really sounds like <code>with_no_trimmed_paths</code> is what I need, but alas no:</p>
<div class="codehilite"><pre><span></span><code><span class="gd">-bx.tcx().def_path_str(inst.def_id())</span>
<span class="gi">+ with_no_trimmed_paths(|| bx.tcx().def_path_debug_str(inst.def_id()))</span>
</code></pre></div>


<p>gives:</p>
<p><code>no warnings or errors encountered even though delayed_good_path_bugs issued</code></p>



<a name="209283744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209283744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209283744">(Sep 07 2020 at 11:11)</a>:</h4>
<p><span class="user-mention" data-user-id="244331">@da-x</span> This seems to be caused by your PR <a href="https://github.com/rust-lang/rust/issues/73996">#73996</a>. Maybe you could help with this.</p>



<a name="209284375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209284375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dan Aloni (da-x) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209284375">(Sep 07 2020 at 11:19)</a>:</h4>
<p>The panic should also gives a full backtrace of the context triggering it</p>



<a name="209286359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209286359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dan Aloni (da-x) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209286359">(Sep 07 2020 at 11:44)</a>:</h4>
<p>Note that there may be two backtraces - the first one should be the one leading up to <code>def_path_str</code>, and would tell you where <code>with_no_trimmed_paths</code> is missing, the second one is just the later diagnostics panicking.</p>



<a name="209289780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209289780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209289780">(Sep 07 2020 at 12:25)</a>:</h4>
<p>Ah, think I got it. It looks like it's caused by debug printing <code>ty.kind</code>?</p>
<div class="codehilite"><pre><span></span><code>  = note: delayed at    0: rustc_errors::Handler::delay_good_path_bug
             1: rustc_middle::ty::print::pretty::trimmed_def_paths
             2: rustc_middle::ty::query::&lt;impl rustc_query_system::query::config::QueryAccessors&lt;rustc_middle::ty::context::TyCtxt&gt; for rustc_middle::ty::query::queries::trimmed_def_paths&gt;::compute
             3: rustc_query_system::dep_graph::graph::DepGraph&lt;K&gt;::with_task_impl
             4: rustc_data_structures::stack::ensure_sufficient_stack
             5: rustc_query_system::query::plumbing::get_query_impl
             6: &lt;rustc_middle::ty::print::pretty::FmtPrinter&lt;F&gt; as rustc_middle::ty::print::Printer&gt;::print_def_path
             7: rustc_middle::ty::print::Printer::default_print_def_path
             8: &lt;rustc_middle::ty::print::pretty::FmtPrinter&lt;F&gt; as rustc_middle::ty::print::Printer&gt;::print_def_path
             9: &lt;rustc_middle::ty::print::pretty::FmtPrinter&lt;F&gt; as rustc_middle::ty::print::pretty::PrettyPrinter&gt;::generic_delimiters
            10: rustc_middle::ty::print::Printer::default_print_def_path
            11: &lt;rustc_middle::ty::print::pretty::FmtPrinter&lt;F&gt; as rustc_middle::ty::print::Printer&gt;::print_def_path
            12: rustc_middle::ty::print::pretty::PrettyPrinter::pretty_print_const
            13: rustc_middle::mir::pretty_print_const
            14: core::fmt::write
            15: &lt;core::fmt::Formatter as core::fmt::Write&gt;::write_fmt
            16: &lt;rustc_middle::mir::Constant as core::fmt::Debug&gt;::fmt
            17: core::fmt::write
            18: alloc::fmt::format
            19: rustc_codegen_ssa::sir::SirFuncCx::lower_operand
            20: rustc_codegen_ssa::sir::SirFuncCx::lower_statement
            21: rustc_codegen_ssa::mir::codegen_mir
...
</code></pre></div>


<div class="codehilite"><pre><span></span><code>385     fn lower_scalar(&amp;self, ty: Ty&lt;&#39;_&gt;, s: mir::interpret::Scalar) -&gt; ykpack::Constant {
386         match ty.kind {
387             ty::Uint(uint) =&gt; self
388                 .lower_uint(uint, s)
389                 .map(|i| ykpack::Constant::Int(ykpack::ConstantInt::UnsignedInt(i)))
390                 .unwrap_or_else(|_| {
391                     ykpack::Constant::Unimplemented(format!(
392                         &quot;unimplemented uint scalar: {:?}&quot;,
393                         ty.kind
394                     ))
395                 }),
</code></pre></div>



<a name="209289985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209289985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209289985">(Sep 07 2020 at 12:27)</a>:</h4>
<p>So assuming that's correct, is there a missing <code>tcx.def_path_debug_str()</code> for constants perhaps?</p>



<a name="209290362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209290362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209290362">(Sep 07 2020 at 12:31)</a>:</h4>
<p>Or perhaps I'm not supposed to be debug printing that late in the compiler</p>



<a name="209306730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209306730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209306730">(Sep 07 2020 at 15:21)</a>:</h4>
<p><span class="user-mention" data-user-id="223288">@Edd Barrett</span> I'm curious: rustc fork?</p>



<a name="209306782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209306782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209306782">(Sep 07 2020 at 15:21)</a>:</h4>
<p>I'll respond in PM so as to keep this thread  on-topic</p>



<a name="209310662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209310662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Edd Barrett <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209310662">(Sep 07 2020 at 16:11)</a>:</h4>
<p>Yes, the problem was that debug impls of some things we were using call <code>def_path_str</code>. Fixed. Thanks!</p>



<a name="209323698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/path%20trimming%20problem/near/209323698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dan Aloni (da-x) <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/path.20trimming.20problem.html#209323698">(Sep 07 2020 at 19:43)</a>:</h4>
<p>Maybe it's worth to mention that with the PR merged, there's a difference in how <code>Display</code> and <code>Debug</code> of various rustc types is implemented. Before this, these two used to emit the same string. Now, path trimming is turned off in the <code>Debug</code> impl, and enabled in the <code>Display</code> impl, which is meant for diagnostics. It's now more similar to the intended use of these traits by Rust developers.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>